<!doctype html>
<html class="no-js">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <title>消息</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <link rel="stylesheet" href="css/amazeui.min.css">
    <link rel="stylesheet" href="css/app.css">
    <link rel="stylesheet" href="css/public2.css">
    <style type="text/css">
    .time_tips {
        width: 2.28rem;
        margin: 0 auto;
        background: #bfbfbf;
        border-radius: 0.2rem;
        text-align: center;
        font-size: 0.2rem;
        color: white;
    }

    .message_content {
        font-size: 50px;
    }

    .message_content img {
        margin-left: 0.36rem;
    }

    .message {
        margin-bottom: 0.7rem;
    }

    .message_text {
        box-shadow: -1px 2px 11px 1px #d8d8d8;
        width: 4.68rem;
        font-size: 0.3rem;
        padding: 0.25rem;
        display: inline-block;
        margin-left: 0.18rem;
        border-radius: 0.1rem;
        vertical-align: middle;
    }

    .am-u-sm-4 {
        font-size: 10px;
    }

    .confirm {
        margin-bottom: 0.7rem;
    }

    .confirm_y {
        display: inline-block;
        width: 1.0rem;
        height: 0.46rem;
        background: #efefef;
        margin-left: 0.5rem;
        margin-top: 0.5rem;
        text-align: center;
        float: left;
    }

    .confirm_n {
        display: inline-block;
        width: 1.0rem;
        height: 0.46rem;
        margin-top: 0.5rem;
        background: #efefef;
        margin-right: 0.5rem;
        text-align: center;
        float: right;
    }

    .confirm .time_tips {
        margin-bottom: 0.4rem;
    }
    </style>
</head>

<body>
    <div class="content">
        <!--<div class="message">-->
            <!--<div class="time_tips">8月20日 15:20</div>-->
            <!--<div class="message_content">-->
                <!--<img src="images/client.png">-->
                <!--<span class="message_text">-->
                   <!--您的申请：8541263541,已通过-->
               <!--</span>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="message">-->
            <!--<div class="time_tips">8月20日 15:20</div>-->
            <!--<div class="message_content">-->
                <!--<img src="images/client.png">-->
                <!--<span class="message_text">-->
                   <!--您的申请：8541263541,未通过-->
               <!--</span>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="message">-->
            <!--<div class="time_tips">8月20日 15:20</div>-->
            <!--<div class="message_content">-->
                <!--<img src="images/client.png">-->
                <!--<span class="message_text">-->
                   <!--您的申请：8541263541,未通过-->
               <!--</span>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="confirm">-->
            <!--<div class="time_tips">8月20日 15:20</div>-->
            <!--<div class="message_content">-->
                <!--<img src="images/client.png">-->
                <!--<span class="message_text">-->
                   <!--河西部门想从您的物资中调用2台空调。<br>-->
                     <!--<span class="confirm_y">OK</span>-->
                <!--<span class="confirm_n">NO</span>-->
                <!--</span>-->
            <!--</div>-->
        <!--</div>-->
        <!--<div class="confirm">-->
            <!--<div class="time_tips">8月20日 15:20</div>-->
            <!--<div class="message_content">-->
                <!--<img src="images/client.png">-->
                <!--<span class="message_text">-->
                   <!--河西部门想从您的物资中调用2台空调。<br>-->
                     <!--<span class="confirm_y">OK</span>-->
                <!--<span class="confirm_n">NO</span>-->
                <!--</span>-->
            <!--</div>-->
        <!--</div>-->

        <!--<div class="confirm">-->
            <!--<div class="time_tips">8月20日 15:20</div>-->
            <!--<div class="message_content">-->
                <!--<img src="images/client.png">-->
                <!--<span class="message_text">-->
                   <!--河西部门想从您的物资中调用2台空调。<br>-->
                     <!--<span class="confirm_y">OK</span>-->
                <!--<span class="confirm_n">NO</span>-->
                <!--</span>-->
            <!--</div>-->
        <!--</div>-->
    </div>
    <div class="footer">
        <a href="javacript:;" class="first-page">
            <div class="am-u-sm-4"><img src="images/index_footer.png"><span>首页</span></div>
        </a>
        <a href="javacript:;" class="message">
            <div class="am-u-sm-4"><img src="images/message_footer.png"><span>消息</span></div>
        </a>
        <a href="javacript:;" class="mine">
            <div class="am-u-sm-4"><img src="images/my_active.png"><span>我的</span></div></a>
    </div>
    <script type="text/javascript" src="js/public.js"></script>
    <script src="./js/jquery.min.js"></script>
    <script src="http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
    <script src="js/amazeui.min.js"></script>
    <script type="application/javascript">
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        var oAccessToken = getQueryString('access-token');
        $('.message').attr('href','./message.html?access-token='+oAccessToken)
        $('.mine').attr('href','./my.html?access-token='+oAccessToken)
        $('.first-page').attr('href','./main.html?access-token='+oAccessToken)


        $.ajax({
            url:'/v1/goods/msg-list?access-token='+oAccessToken,
            type:'post',
            data:'',
            success:function(data){
                if(data.status == 200){
                    var html ='';
                    var len =data.body.length;
                    for(let i=0;i<len;i++){
                        if( data.body[i].is_pass == 1 ){
                            html += '<div class="confirm"><div class="time_tips">'+data.body[i].ctime+'</div><div class="message_content"><img src="images/client.png">'+
                                '<span class="message_text">'+data.body[i].content+'<br><span class="confirm_y" yid="'+data.body[i].id+'" cid="'+data.body[i].cid+'">OK</span><span class="confirm_n" nid="'+data.body[i].id+'" cid="'+data.body[i].cid+'">NO</span></span></div></div>';
                        }else{
                            html += '<div class="message"> <div class="time_tips">'+data.body[i].ctime+'</div> <div class="message_content"><img src="images/client.png">'+
                                    '<span class="message_text">'+data.body[i].content+'</span> </div> </div>';
                        }
                    }
                    $('.content').html(html);
                    var aYes  = $('.confirm_y');
                    var aNo   = $('.confirm_n');

                    $(aYes).each(function () {
                        $(this).click(function () {
                           $.ajax({
                               url:'/v1/goods/msg-pass?access-token='+oAccessToken,
                               type:'post',
                               data:{
                                   id:$(this).attr('yid'),
                                   cid:$(this).attr('cid'),
                               },
                               success:function(){
                                   if( data.status == 200 ){
                                       window.location.href = './message.html?access-token='+oAccessToken;
                                   }
                               },
                               error:function(){
                                   if( data.status == 401 ){
                                       window.location.href = './index.html';
                                   }
                               },
                           })
                        })
                    })
                    $(aNo).each(function () {
                        $(this).click(function () {
                            $.ajax({
                                url:'/v1/goods/msg-veto?access-token='+oAccessToken,
                                type:'post',
                                data:{
                                    id:$(this).attr('nid'),
                                    cid:$(this).attr('cid'),
                                },
                                success:function(data){
                                    if( data.status == 200 ){
                                        window.location.href = './message.html?access-token='+oAccessToken;
                                    }
                                },
                                error:function(data){
                                    if( data.status == 401 ){
                                        window.location.href = './index.html';
                                    }
                                },
                            })
                        })
                    })

                }else{
                    alert(data.msg)
                }
            },
            error:function(data){
                if(data.status == 401){
                    window.location.href = './index.html';
                }
            }
        })
        $(function () {

        })


    </script>
</body>

</html>